var baseUrl =`http://localhost:4000/api`
function http(url){
    return new Promise((resolve,reject)=>{
        wx.request({
            url: baseUrl+url,
            data: {},
            method: 'GET', 
            success:(res)=>{
                resolve(res)
            },
            fail:(err)=>{
                reject(err)
            },
           
        })
    })
}
function getTop250Http(){
    return http("/top250")
}
function getItemHttp(id){
    return http(`/subject?id=${id}`) 
}
function getLunHttp(){
    return S("/banner")
}
function handleStar(num) {
    var arr = []
    for (var i = 0; i < 5; i++) {
        if (num >= 2) {
            arr.push(2)
        } else if (num > 0) {
            arr.push(Number(num.toFixed(1)))
        } else {
            arr.push(0)
        }
        num = num - 2
    }

    return arr;
}
module.exports={
    getTop250Http,
    getItemHttp,   
    handleStar ,
    getLunHttp
}